<template>
    <div class="flex1 flex-col">
        <div class="panel _body flex1 flex-col">
            <!-- 资源列表 -->
            <div class="flex1">
                <div class="twlb-item flex-row"
                     v-for="oItem in aTable"
                     :key="oItem.id">
                    <el-image class="twlb-image"
                              :src="oItem.imgurl"
                              :preview-src-list="[oItem.imgurl]">
                        <div slot="error"
                             class="twlb-image-error">
                        </div>
                    </el-image>
                    <div class="flex1 flex-col twlb-item-nr">
                        <div class="twlb-item-bt"
                             :title="oItem.name">{{oItem.name || '-'}}</div>
                        <div class="twlb-item-zy"
                             :title="oItem.zynr">{{oItem.zynr || '-'}}</div>
                        <div class="flex-row twlb-item-zt">
                            <div class="twlb-item-ztbq">{{fSetZt(oItem.zt)}}</div>
                            <div class="flex-row">
                                <div class="twlb-item-btn"
                                     v-if="oItem.zt === '1'"
                                     @click="fBtnClick('submit',oItem)">
                                    <i class="el-icon-upload2"></i> 提交
                                </div>
                                <div class="twlb-item-btn"
                                     v-if="oItem.zt === '1'"
                                     @click="fBtnClick('edit',oItem)">
                                    <i class="el-icon-edit"></i> 编辑
                                </div>
                                <div class="twlb-item-btn"
                                     v-if="oItem.zt !== '5'"
                                     @click="fBtnClick('view',oItem)">
                                    <i class="el-icon-view"></i> 浏览
                                </div>
                                <div class="twlb-item-btn _delete"
                                     v-if="oItem.zt === '1'"
                                     @click="fBtnClick('delete',oItem)">
                                    <i class="el-icon-delete"></i> 删除
                                </div>
                                <div class="twlb-item-btn"
                                     v-if="oItem.zt === '2'"
                                     @click="fBtnClick('withdraw',oItem)">
                                    <i class="el-icon-refresh-left"></i> 撤回
                                </div>
                                <div class="twlb-item-btn"
                                     v-if="oItem.zt === '3'"
                                     @click="fBtnClick('grounding',oItem)">
                                    <i class="el-icon-top"></i> 上架
                                </div>
                                <div class="twlb-item-btn"
                                     v-if="oItem.zt === '4'"
                                     @click="fBtnClick('undercarriage',oItem)">
                                    <i class="el-icon-bottom"></i> 下架
                                </div>
                                <div class="twlb-item-btn"
                                     v-if="oItem.zt === '5'"
                                     @click="fBtnClick('file',oItem)">
                                    <i class="el-icon-files"></i> 归档
                                </div>
                                <div class="twlb-item-btn"
                                     v-if="oItem.zt === ''"
                                     @click="fBtnClick('examine',oItem)">
                                    <i class="el-icon-s-promotion"></i> 审核
                                </div>
                            </div>
                        </div>
                        <div class="twlb-item-sj">{{'发布时间：'+ (oItem.fbsj || '-') + ' 添加时间：'+ (oItem.tjsj || '-')}}</div>
                    </div>
                </div>
            </div>
            <!-- 分页条 -->
            <wiv-pagebar ref="pagebar"
                         @after-flip="fAfterFlip"></wiv-pagebar>
        </div>
    </div>
</template>

<script>
    import { URLS_DEMO } from '@/urls.js';

    export default {
        data() {
            return {
                aTable: [], //表格数据
            }
        },
        mounted() {
            this.$refs.pagebar.fReset({
                url: URLS_DEMO.d_twlb
            });
        },
        methods: {
            fAfterFlip(aData, oPageApi) { //分页组件回调
                this.aTable = aData;
            },
            fBtnClick(sType, oData) { //列表按钮点击事件
                switch (sType) {
                    case 'submit': //提交
                        break;
                    case 'edit': //编辑
                        break;
                    case 'view': //浏览
                        break;
                    case 'delete': //删除
                        break;
                    case 'withdraw': //撤回
                        break;
                    case 'grounding': //上架
                        break;
                    case 'undercarriage': //下架
                        break;
                    case 'file': //归档
                        break;
                    case 'examine': //审核
                        break;
                }
            },
            fSetZt(sVal) { //判断数据项的状态
                switch (sVal) {
                    case '1':
                        return '草稿';
                    case '2':
                        return '审核中';
                    case '3':
                        return '待发布';
                    case '4':
                        return '已发布';
                    case '5':
                        return '已下架';
                }
            },
        }
    }
</script>

<style>
</style>